#!/bin/bash
CFSSL_VERSION=1.4.1

BIN_DIR=/opt/k8s/bin
WORK_DIR=/opt/soft/cfssl

echo "cfssl verssion: ${CFSSL_VERSION}"

# mkdir -p /opt/soft
# mkdir -p /opt/soft/cfssl

if [ ! -d ${BIN_DIR} ]; then mkdir -p ${BIN_DIR}; fi
if [ ! -d ${WORK_DIR} ]; then mkdir -p ${WORK_DIR}; fi

cd ${WORK_DIR}
wget -c https://github.com/cloudflare/cfssl/releases/download/v${CFSSL_VERSION}/cfssl_${CFSSL_VERSION}_linux_amd64
mv cfssl_${CFSSL_VERSION}_linux_amd64 ${BIN_DIR}/cfssl

wget -c https://github.com/cloudflare/cfssl/releases/download/v${CFSSL_VERSION}/cfssljson_${CFSSL_VERSION}_linux_amd64
mv cfssljson_${CFSSL_VERSION}_linux_amd64 ${BIN_DIR}/cfssljson

wget -c https://github.com/cloudflare/cfssl/releases/download/v${CFSSL_VERSION}/cfssl-certinfo_${CFSSL_VERSION}_linux_amd64
mv cfssl-certinfo_${CFSSL_VERSION}_linux_amd64 ${BIN_DIR}/cfssl-certinfo

chmod +x ${BIN_DIR}/*